/**
 * Copyright(C) 2019 FUYUN DATA SERVICES CO., LTD. - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 * 该源代码版权归属福韵数据服务有限公司所有
 * 未经授权，任何人不得复制、泄露、转载、使用，否则将视为侵权
 */

import request from "../../../../utils/request";
import { stringify } from "querystring";
import { SERVER_URL } from "../../../../config/base";

// 查询用户列表数据
export async function getUserList(payload: any) {
  return request(`${SERVER_URL}/sysUser?${stringify(payload)}`, {
    method: "get",
    data: {}
  });
}

// 根据id查询用户信息
export async function getUserById(id: any) {
  return request(`${SERVER_URL}/sysUser/` + id, {
    method: "get",
    data: {}
  });
}

// 修改用户信息
export async function modifyUser(payload: any) {
  return request(`${SERVER_URL}/sysUser/` + payload.id, {
    method: "put",
    data: {
      ...payload
    }
  });
}

// 保存用户信息
export async function saveUser(payload: any) {
  return request(`${SERVER_URL}/sysUser/`, {
    method: "post",
    data: {
      ...payload
    }
  });
}

// 绑定权限菜单
export async function saveRole(payload: any) {
  return request(`${SERVER_URL}/sysUser/saveRole`, {
    method: "post",
    data: payload
  });
}

export async function bindRole(userId: any) {
  return request(`${SERVER_URL}/sysUser/bindRole?userId=` + userId, {
    method: "get",
    data: {}
  });
}

export async function deleteRole(userId: any) {
  return request(`${SERVER_URL}/sysUser/deleteRole?userId=` + userId, {
    method: "delete",
    data: {}
  });
}

export async function login(payload: any) {
  return request(`${SERVER_URL}/sysUser/login`, {
    method: "post",
    data: payload
  });
}
